package com.zgq.share.thirdplatform;

import java.util.HashMap;
import java.util.Map;

import android.content.Context;

import com.zgq.share.thirdplatform.renren.RenrenAdapter;
import com.zgq.share.thirdplatform.sina.SinaAdapter;
/*import com.zgq.share.thirdplatform.tencent.TencentAdapter;*/

/**
 * 第三方平台工厂
 * @author Administrator
 *
 */
public class PlatformFactory {
	private static Map<String, IPlatform> platforms = new HashMap<String, IPlatform>();
	
	public static IPlatform getPlatform(Context context, PlatformType type) {
		IPlatform res;
		String key = type.getName();
		if (platforms.containsKey(key)) {
			res = platforms.get(key);
			res.setContext(context);
			return res;
		}

		switch(type.getValue()) {
		case PlatformDefs.SINA:
			res = new SinaAdapter(context);
			platforms.put(key, res);
			
			return res;
			
		case PlatformDefs.RENREN:
			res = new RenrenAdapter(context);
			platforms.put(key, res);
			
			return res;
			
		/*case PlatformDefs.TENCENT:
			res = new TencentAdapter(context) ;
			platforms.put(key, res);
			
			return res;*/
		}
		
		return null;
	}
}
